<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<div style="width: 350px" id="project">
    <form class="layui-form" action="" onsubmit="return false" id="newProject">
        <input type="hidden" name="id" value="{$info.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="title" value="{$info.title}" placeholder="请输入项目名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单位</label>
            <div class="layui-input-block">
                <input type="text" name="company" id="company" value="{$info.company}" placeholder="单位" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="update">立即保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>
    layui.use('form', function(){
        var form = layui.form;
    });
</script>
<script>
    //添加体育项目
    $("#update").click(function () {
        if(!$("#title").val()){
            layer.msg('项目名称不能为空',{icon:5,time:2000});
            return;
        }
        if(!$("#company").val()){
            layer.msg('项目单位不能为空',{icon:5,time:2000});
            return;
        }
        $.ajax({
            url:"{:url('/sports_project/projectUpdate')}",
            type:"post",
            data:$("#newProject").serialize(),
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        });
    })
</script>
</html>